(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Usage of Rosserial_arduino with STM32F429ZI NUCLEO board

Description: This tutorial will guide you to use rosserial_arduino with a stm32f4 nucleo board. I've used PlatformIO for VSCode as IDE, but Arduino IDE would will also work.

Keywords: rosserial, ros, arduino, stm32

Tutorial Level: BEGINNER

Contents

  1. Usage

Usage

To simply use any of the hardware serials on the board, you can define a HardwareSerial object on Serial1, which the rosserial_arduino uses as a default for stm32 boards.

   1 #define ROSMASTER_RX                        PD6     // NUCLEO-F429ZI UART2-RX
   2 #define ROSMASTER_TX                        PD5    // NUCLEO-F429ZI UART2-TX
   3 #include "HardwareSerial.h"
   4 HardwareSerial hserial(ROSMASTER_RX, ROSMASTER_TX);
   5 
   6 // This will overwrite the current Serial1 serial port and will use hserial port.
   7 #define Serial1 XavierSerial
   8 
   9 // This define statement should be defined before including ros.h
  10 #define USE_STM32_HW_SERIAL
  11 
  12 #include <ros/ros.h>
  13 
  14 void setup()
  15 {
  16 
  17 }
  18 ...

Also, you can directly access the hardware object with these lines in setup() function.

   1 void setup()
   2 {
   3     nh.getHardware()->iostream = &my_custom_HardwareSerialObject;
   4     nh.getHardware()->setBaud(9600);
   5     nh.initNode();
   6 }

For further questions, you can contact me by senceryazici@gmail.com If there are any problems with the codes I provided, please let me know. I tested them and it worked for me.

Wiki: rosserial_arduino/Tutorials/Example of usage with STM32F4 (last edited 2019-08-01 08:08:05 by SencerYazici)